// Copyright 2022 jeff.li. and/or its affiliates.

#pragma once

#include <tbir/runtime/env_time.h>
#include <tbir/runtime/logging.h>

namespace tbir::runtime {

    struct TimeLine {
        uint64_t stamp_start = 0;
        uint64_t stamp_end = 0;
    };

    class ProfilingHelper {
    public:
        explicit ProfilingHelper(TimeLine *tl = nullptr) {
            time_line_ = tl;
            if (time_line_) {
                time_line_->stamp_start = EnvTime::Default()->NowNanos();
            }
        }

        ~ProfilingHelper() {
            if (time_line_) {
                time_line_->stamp_end = EnvTime::Default()->NowNanos();
            }
        }

    private:
        TimeLine *time_line_;
    };

}  // namespace tbir::runtime
